<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="yaodian100" uri="http://www.yaodian100.com/jsp/yaodian100" %>
<%@ include file="/taglibs.jsp"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<link rel="stylesheet" type="text/css" href="${midContextPath}/css/validator.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="/css/ui.jqgrid.css" />
<style type="text/css" media="screen">
 <!-- 
  SELECT.selCont{ margin: 10px; width: 300px; }
  select.selCont1{ margin: 10px; width: 960px; }
  -->
</style> 
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="${midContextPath}/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="${midContextPath}/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="${midContextPath}/css/smoothness.datepick.css"/>
<script src="/js/grid.locale-en.js" type="text/javascript"></script>
<script src="/js/jquery.jqGrid.min.js" type="text/javascript" charset="UTF-8"></script>
<s:url var="supplierPops" value="/json/supplierPops.do"/>
<s:url var="brandPops" value="/json/brandPops.do"/>
<script src="${midContextPath}/ckeditor/ckeditor.js" type="text/javascript"></script>
<script src="${midContextPath}/js/yaodian100.common.js" type="text/javascript"></script>
<script type="text/javascript"> 
	var content;
	var qry_target = '01';
 	$(function() {
 	 	//导入描述图
 	 	$("#loadDescImg").click(function(){
 	 		doAR('${midContextPath}/product2/loadDescImg.do?productId=${product.productId}', 'dialog'); 
			openDialog('导入描述图',content, 650, 500);
 	 	});
 		calcVolume();
 		//載入主分類設定
 		if ( "" != $("#mainCategoryPath").val()){ 
 			$("#tempCategoryPath").val($("#mainCategoryPath").val());
 			$("#mainCategoryFullPath").text($("#tempCategoryFullPath").val());
 			loadDefaultCategory();
 			var tempId = $("#mainCategoryPath").val().split("/");
 			if ( $("#orderNotice").val() == "" )
 				$.post("${midContextPath}/product2/loadOrderNotice.do",{categoryId:tempId[0]},orderNoticeCallback,"json");
 		}
 		 	 	
 		//設為主分類
 		$("#mainCateBtn").click(function(){
 			ydClean("mainCategoryFullPath");
 			if ($('#tempCategoryId').val()==""){
 				return ydValidate("mainCategoryFullPath","请选择主分类");
 			}
			if ( $("#isEndNode").val() == "N"){//判断此目录是否为最底层
				return ydValidate("mainCategoryFullPath","请选择最底层的目录");
			}
			if ( duplicateCategoryIsExist($("#tempCategoryId").val()) ){//判断是否加入重复的目录
				return ydValidate("mainCategoryFullPath","请勿加入重复的目录");
			}
			$("#mainCategoryId").val($("#tempCategoryId").val());
			$("#mainCategoryPath").val($("#tempCategoryPath").val());
			$("#mainCategoryFullPath").text($("#tempCategoryFullPath").val());
 		});
 		//設為次分類
 		$("#secondCateBtn").click(function(){
 			ydClean("secondCategoryFullPath");
 			if ($('#mainCategoryId').val()==""){
 				return ydValidate("mainCategoryFullPath","请选择主分类");
 			}
 			if ($("#tempCategoryPath").val() == "" ){
 				return ydValidate("secondCategoryFullPath","请选择次分类");
 			}
 			if ( $("#tempCategoryId").val() != ""){
 				if ( $("#isEndNode").val() == "N"){//判断此目录是否为最底层
					return ydValidate("secondCategoryFullPath","请选择最底层的目录");
 				}
 				if ( duplicateCategoryIsExist($("#tempCategoryId").val()) ){//判断是否加入重复的目录
 					return ydValidate("secondCategoryFullPath","请勿加入重复的目录");
 				}
 				$('#secondCategoryId').val($("#tempCategoryId").val());
 	 			$('#secondCategoryPath').val($("#tempCategoryPath").val());
 	 			$("#secondCategoryFullPath").text($("#tempCategoryFullPath").val());
 	 			var addOnDataText = $("#secondCategoryFullPath").text() + ",[]" + "," +$("#secondCategoryPath").val();
 	 			var addOnDataValue = ""; 				
				addOnDataValue=$("#secondCategoryId").val() + "," + $("#secondCategoryPath").val() + ",101";
				$('#addOnSelect').append($("<option></option>").attr("value",addOnDataValue).text(addOnDataText));
 			}
 			$("#secondCategoryFullPath").text("");
 		}); 	 	 	

 		//点选清除button
 		$("#clearDataContext").click(function(){
 			clear_form_elements();
 		});


 		//編輯時select選取反白要修改的商品
 		if($("#tempCategoryId").val()!=""){
 			$('#addOnSelect option').each(function(){		
 				if(this.value.split(",")[0]==$("#tempCategoryId").val()){	
 					$(this).attr("selected","true"); 
 				}									
 			});
 		}
 		
 		//移除select的商品	
 		$("#removeSelect").click(function(){
 				var sel = $("#addOnSelect option:selected");
 				$(sel).remove();
 				$("#secondCategoryFullPath").html("");		
 		});		

 		//移除所有select的商品	
 		$("#removeAllSelect").click(function(){
 			$('#addOnSelect option').each(function(){		
 					$(this).remove();
 			});			
 			$("#secondCategoryFullPath").html("");		
 		});	

 		//点选select里的item，自动将资料带到上方的栏位中
 		$("#addOnSelect").click(function(){	
 			ydClean("secondCategoryFullPath");
 			var sel = $("#addOnSelect option:selected");
 			$("#tempCategoryId").val($(sel).val().split(",")[0]);		
 			$("#tempCategoryPath").val($(sel).val().split(",")[1]);	
 			$("#addonShowSeq").val($(sel).val().split(",")[2]);	
 			$("#secondCategoryFullPath").text($(sel).text().split(",")[0]);
 			if ( checkPermission($("#tempCategoryPath").val())){
 				loadDefaultCategory();
 				$("#secondCateBtn").css("display","inline-block");
 			}else{
 				$("#secondCateBtn").css("display","none");
 				ydValidate("secondCategoryFullPath","抱歉你无权限编辑该目录，若要移除请按移除钮");
 			}	
 		});	
 		 		
	 	<c-rt:if test="${product.supplierId eq '010000' or product.supplierId eq '010001'}">
			$("#twSupplier").show();
			<c-rt:if test="${not empty product.productId and not empty product.twSupplierId}">
				$("#getTwSupplier").hide();
			</c-rt:if>
		</c-rt:if> 	 	
		<c-rt:if test="${not empty product.productId}">
	 		if ( $("#supplierIdParam").val() != ""){
			$("#supplierIdParam").attr("readonly",true);
			$("#getSupplier").hide();
		}
		</c-rt:if>
		<c-rt:choose>
			<c-rt:when test="${not empty product.productId and product.isScm eq 'Y'}">
				$("#showScmNotice").show();
				dispScmNotice();
			</c-rt:when>
			<c-rt:otherwise>
				var notice = CKEDITOR.instances['scmNotice'];
				if(notice){
					notice.destroy();
					CKEDITOR.remove(notice);
				}
				$("#showScmNotice").hide();
			</c-rt:otherwise>
		</c-rt:choose>
		
		<c-rt:if test="${empty product.productId}">
		$("#isScmY").click(function() {
			$("#showScmNotice").show();
			dispScmNotice();
			$("#canUseCodTr").hide();
		});	 
		$("#isScmN").click(function() {
			var notice = CKEDITOR.instances['scmNotice'];
			if(notice){
				notice.destroy();
				CKEDITOR.remove(notice);
			}
			$("#showScmNotice").hide();
			$("#canUseCodTr").show();
		});	
		$("#isScmB").click(function() {
			var notice = CKEDITOR.instances['scmNotice'];
			if(notice){
				notice.destroy();
				CKEDITOR.remove(notice);
			}
			$("#showScmNotice").hide();
			$("#canUseCodTr").show();
		});		
		if ( $('#isScmN:checked').val() == 'N' || $('#isScmB:checked').val() == 'B'){
			var notice = CKEDITOR.instances['scmNotice'];
			if(notice){
				notice.destroy();
				CKEDITOR.remove(notice);
			}
			$("#showScmNotice").hide();
			$("#canUseCodTr").show();
		}else{
			$("#showScmNotice").show();
			dispScmNotice();
			$("#canUseCodTr").hide();
		}
		</c-rt:if>
		//BO及SCM商品才可开立预购和订制卖场
	 	<c-rt:choose>
			<c-rt:when test="${(product.productType eq '0' or product.productType eq '1') and not empty product.isScm and product.isScm ne 'N' }">
				$("#showUseDeliveryDay").show();
			</c-rt:when>
			<c-rt:otherwise>
				$("#showUseDeliveryDay").hide();
			</c-rt:otherwise>
		</c-rt:choose>
		$('input[name=useDeliveryDay]').each(function(){
			 $(this).click(function(){
				 if ( $(this).val() == "Y" ){
			 	 		$("#showDeliveryDay").show();
			 	 }else{
			 		$("#showDeliveryDay").hide();
			 	 }
				 $("#deliveryDay").val("0");
			 });
		 });
		$("#getSupplier").click(function() {
			$("#spId").val("");
			$("#spName").val("");
			doAR('${supplierPops}', 'dialog'); 
			openDialog('供应商搜寻',content, 550, 440);
		});	 
		$("#getTwSupplier").click(function() {
			$("#spId").val("twSupplierIdParam");
			$("#spName").val("twSupplierCompanyName");
			doAR('${supplierPops}', 'dialog'); 
			openDialog('供应商搜寻',content, 550, 440);
		});	 
		$("#getBrand").click(function() {
			doAR('${brandPops}', 'dialog'); 
			openDialog('品牌搜寻',content, 550, 440);
		});	
	 $("#loadingImg").dialog({
		  title: '资料载入中',
			bgiframe: true,
			autoOpen: false,
			height: 150,
			width:280,
			modal: true
		});
	 $('#expectShipDate').datepick({minDate: '+1D', maxDate: '+45D',showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '<%=ServerValue.getMidContextPath()%>/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-1:+1'});

	 $("input[name=isScm]").each(function(){
		 $(this).click(function(){
			 initType($(this).val());
		 });
	 });
	<c-rt:if test="${not empty product.productId}">
		initType("${product.isScm}");
 		initDeliveryDay("${product.isScm}","${product.productType}");
 		<c-rt:if test="${not empty product.productType}">
			$("input[name=type][type=radio]").each(function(){
	 				if ( $(this).val() == "${product.productType}" ){
	 	 				$(this).attr("checked",true);	
	 				}else{
	 					$(this).attr("checked",false);
	 				}
			});
			if ( "1" == "${product.productType}" ){
				$("#showExpectShipDate").show();
			}
		</c-rt:if>
		<c-rt:if test="${product.useDeliveryDay eq 'Y'}">
			$("input[name=useDeliveryDay][type=radio]").eq(0).attr("checked", true);
			$("#showDeliveryDay").show();
			$("#deliveryDay").val("${product.deliveryDay}");
		</c-rt:if>
 	</c-rt:if>
 	<c-rt:if test="${empty product.productId}">
 		initType("B");
 	</c-rt:if>
 	<c-rt:if test="${empty product.productId and copy eq 'Y'}">
 		initType("${isScm}");
		initDeliveryDay("${isScm}","${type}");
		<c-rt:if test="${not empty type}">
			$("input[name=type][type=radio]").each(function(){
				if ( $(this).val() == "${type}" ){
	 				$(this).attr("checked",true);	
				}else{
					$(this).attr("checked",false);
				}
			});
			if ( "1" == "${type}" ){
				$("#showExpectShipDate").show();
			}
		</c-rt:if>	
 	</c-rt:if>
 	
	 $("input[name=type]").each(function(){
		 $(this).click(function(){
			<c-rt:choose>
				<c-rt:when test="${not empty product.productId and product.isScm ne 'B'}">
				initDeliveryDay("${product.isScm}",$(this).val());
				</c-rt:when>
				<c-rt:otherwise>
					initDeliveryDay($('input[name=isScm]:radio:checked').val(),$(this).val());
				</c-rt:otherwise>
			</c-rt:choose>
		 });
	 });
	 if ( $('input[name=type]:checked').val() == 1) $("#showExpectShipDate").show();
	 
	 $("#supplierIdParam").onlyInteger();
	 $("#length").ydPrice();
	 $("#width").ydPrice();
	 $("#height").ydPrice();
	 $("#weight").onlyInteger();
	 $("#tax").ydPrice();
	 $("#showSeq").onlyInteger();
	 $("#cost").ydPrice();
	 $("#price").ydPrice();
	 $("#prpsShelfPrice").ydPrice();
	 $("#deliveryDay").onlyInteger();

	 //計算體積
	 $("#length").blur(function(){
		 calcVolume();
	 });
	 
	 $("#width").blur(function(){
		 calcVolume();
	 });

	 $("#height").blur(function(){
		 calcVolume();
	 });
	//长
	if ( "" == "${product.productLength}" || 0 == "${product.productLength}"  ){
		$("#length").val("请输入整数").attr("class","txt-gy");
	}
			
	$("#length").focus(function(){
		if($("#length").val()=='请输入整数')
			$("#length").val("").removeClass("txt-gy");
	}).blur(function(){
		if($("#length").val()=='')
			$("#length").val("请输入整数").attr("class","txt-gy");
	});

	//宽
	if ( "" == "${product.productWidth}" || 0 == "${product.productWidth}" )
				$("#width").val("请输入整数").attr("class","txt-gy");
			
	$("#width").focus(function(){
		if($("#width").val()=='请输入整数')
			$("#width").val("").removeClass("txt-gy");
	}).blur(function(){
		if($("#width").val()=='')
			$("#width").val("请输入整数").attr("class","txt-gy");
	});	
	
	//高
	if ( "" == "${product.productHeight}" || 0 == "${product.productHeight}" )
				$("#height").val("请输入整数").attr("class","txt-gy");
			
	$("#height").focus(function(){
		if($("#height").val()=='请输入整数')
			$("#height").val("").removeClass("txt-gy");
	}).blur(function(){
		if($("#height").val()=='')
			$("#height").val("请输入整数").attr("class","txt-gy");
	});	

	//重量
	if ( "" == "${product.productWeight}" || 0 == "${product.productWeight}" )
				$("#weight").val("请输入整数").attr("class","txt-gy");
			
	$("#weight").focus(function(){
		if($("#weight").val()=='请输入整数')
			$("#weight").val("").removeClass("txt-gy");
	}).blur(function(){
		if($("#weight").val()=='')
			$("#weight").val("请输入整数").attr("class","txt-gy");
	});	

	//銷售單位
	if ( "" == "${product.productUnit}" )
				$("#unit").val("例如：件、个、罐、只").attr("class","txt-gy");
			
	$("#unit").focus(function(){
		if($("#unit").val()=="例如：件、个、罐、只")
			$("#unit").val("").removeClass("txt-gy");
	}).blur(function(){
		if($("#unit").val()=='')
			$("#unit").val("例如：件、个、罐、只").attr("class","txt-gy");
	});					

	//第0层
	$("#categorySelect").click(function(){
		if ( null != $(this).val()  ){
			<c-rt:if test="${empty product.productId and copy eq 'N'}">
		    if ( $(this).val() == "1726" || $(this).val() == "1727" || $(this).val() == "1728" ){
		    	$('input[name=graphicType]').get(1).checked = true;
		    	$('input[name=graphicType]').get(0).checked = false;
		    }else{
		    	$('input[name=graphicType]').get(1).checked = false;
		    	$('input[name=graphicType]').get(0).checked = true;
		    }
		  </c-rt:if>
			$.post("${midContextPath}/product2/loadOrderNotice.do",{categoryId:$(this).val()},orderNoticeCallback,"json");
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'elementSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
						$('#elementSelect').find('option').remove().end();
				 		$('#attributeSelect').find('option').remove().end();
				 		$('#itemSelect').find('option').remove().end();
				 		$('#unitSelect').find('option').remove().end();
				 		$('#listSelect').find('option').remove().end();					
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	elementSelectCallback(strData);
				}
			});
		}
		$("#tempCategoryId").val($(this).val());
		getCategoryPath();
		checkIsEndNode();
	});
	//第1层
	$("#elementSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'attributeSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
						$('#attributeSelect').find('option').remove().end();
					  $('#itemSelect').find('option').remove().end();
					  $('#unitSelect').find('option').remove().end();
					  $('#listSelect').find('option').remove().end();						
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	attributeSelectCallback(strData);
				}
			});	  
			$("#tempCategoryId").val($(this).val());
			getCategoryPath();
			checkIsEndNode();
		}
	});
	//第2层
	$("#attributeSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'itemSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
					  $('#itemSelect').find('option').remove().end();
					  $('#unitSelect').find('option').remove().end();
					  $('#listSelect').find('option').remove().end();
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	itemSelectCallback(strData);
				}
			});	  	
			$("#tempCategoryId").val($(this).val());
			getCategoryPath();
			checkIsEndNode();
		}
	});
	//第三层
	$("#itemSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'unitSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
					  $('#unitSelect').find('option').remove().end();
					  $('#listSelect').find('option').remove().end();
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	unitSelectCallback(strData);
				}
			});	 	  	
			$("#tempCategoryId").val($(this).val());
			getCategoryPath();
			checkIsEndNode();
		}
	});
	//第四层
	$("#unitSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'listSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
						$('#listSelect').find('option').remove().end();
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	listSelectCallback(strData);
				}
			});	  	
			$("#tempCategoryId").val($(this).val());
			getCategoryPath();
			checkIsEndNode();
		}
	});		
	//第五层
	$("#listSelect").click(function(){
		if ( null != $(this).val()  ){
			$("#tempCategoryId").val($(this).val());
			getCategoryPath();
			checkIsEndNode();
		}
	});				  
	    
	$("input[name*='submit']").click(function(){
		$("#saveFlag").val($(this).attr("id"));
		validate_data();
	});
 });

	function dispScmNotice(){
		var notice = CKEDITOR.instances['scmNotice'];
		if(notice){
			notice.destroy();
			CKEDITOR.remove(notice);
		}
		CKEDITOR.replace('scmNotice',{toolbar : 'product'});
		CKEDITOR.config.contentsCss='/css/yaodian100_pdpagese_v2.css';
	}
	function chk24hr(){
		if ( "${product.productType}" == 6 ){
			alert("N选M商品不可异动供应商");
		//}else if ( "${product.supplierId}" == "010000" || "${product.supplierId}" == "010001" ){
		//alert("台湾供应商的商品不允许更换普通供应商与台湾供应商");
		}else if ( "${product.isScm}" == "Y" ){
			alert("SCM转单商品不可异动供应商");
		}else if ( parseInt("${approveSize}",10) > 0){
			alert("申请中的供应商请等待已审核后再申请");
		}else if ( "${not empty addonsMain}" == "true" ){
			alert("搭售主商品不可异动供应商");			
		}else if ( "${not empty addons}" == "true" ){
			alert("该商品有设成搭售，请先移除搭售设定");
		}else if ( "${not empty nms}" == "true" ){
			alert("该商品有设成n选m，请先移除搭售设定");
		}else if ( "${chkHasInventory}" == "true"){
			alert("该商品尚有库存不可异动供应商");
		}else{
			$.post("${midContextPath}/product2/jsonChk24Hr.do",{productId:'${product.productId}'},callback,"json");
		}
	}
	function callback(hr24Result){
		if ( null == hr24Result )
			location.href="${midContextPath}/productSupplierApprove/add.do?productId=${product.productId}";
		else
			alert(hr24Result);
		return false ;
	}	
 	function disabledBtn(){
 		$("input[type='button']").each(function(){
			$(this).attr("disabled","disabled");
		});
   	if($("#productAttribute").val()=='Y' ||$("#productAttribute").val()=='H' || $("#productAttribute").val()=='Q'){
		  var sProdStatus="";
		  if($("#productAttribute").val()=='Y'){
		   sProdStatus="Y-不可查询,不可销售";
		  }
		  if($("#productAttribute").val()=='H'){
		   sProdStatus="H-不可查询,可销售";
		  }
		  if($("#productAttribute").val()=='Q'){
		   sProdStatus="Q-可查询,不可销售";
		  }
			if(window.confirm('本商品之销售状态设为'+sProdStatus+'，是否确认？')){
				$("#productForm").submit();
			}else{
				$("input[type='button']").each(function(){
					$(this).attr("disabled","");
				});
				return false;
			}
		}else{
			$("#productForm").submit();
		}
 	}

	function getCategoryPath(){
		$.getJSON("${midContextPath}/product2/findCategoryPath.do",{categoryId:$("#tempCategoryId").val()},categoryPathCallback);
	}
	function categoryPathCallback(jsonCategoryPath){
		$("#tempCategoryPath").val(jsonCategoryPath);
	}
	 	
	 function validate_data(){
		  $("div.errmsg").remove();
		 	var brief_result = true;
		 	var flag = "";
		 	var err = 0;
		 	$("#flag").val(flag);
		 	if ($("#name").val() == "" ){
		 		ydValidate("name","请输入商品名称");
		 		err++;
			}
			<c-rt:if test="${empty product.productId}">
			if ( $('input[name=isScm]').is(":checked") == false ){
				ydValidate("scmMode","请选择采购类型");
				err++;
			}
			</c-rt:if>
			if ($('input[name=type]').is(":checked") == false){
				ydValidate("typeMode","请输入商品型态(一般商品,预购,赠品,配件)");
				err++;
			}
			if ( $('input[name=isScm]:checked').val() == 'Y' || $('input[name=isScm]:checked').val() == 'B' ){
				if ( $('input[name=type]:checked').val() == "0" || $('input[name=type]:checked').val() == "1" ){
					if ( $('input[name=useDeliveryDay]:checked').val() == 'Y'){
						if ( $("#deliveryDay").val() == "" || parseInt($("#deliveryDay").val(),10) == 0 ){
							ydValidate("deliveryDay","订制商品天数不可为空值且必须大于0天");
							err++;
							$("#useDeliveryDay").focus();
							return false;
						}
					}
				}
			}			
			if ($('#mainCategoryId').val()==""){
				ydValidate("mainCategoryFullPath","请输入主目录");
				err++;
			}			
			var addData="";				
			var nonePermission = "";
			addData = $("#mainCategoryId").val() +",101;";
			$('#addOnSelect option').each(function(){
				if ( checkPermission($(this).text().split(",")[2]) ){
					nonePermission = nonePermission + $(this).val().split(",")[0];
				}
				addData = addData + $(this).val().split(",")[0] + "," + $(this).val().split(",")[2] + ";";
			});
			$("#finalAddOnData").val(addData);
			if ( $('input[name=type]:checked').val() == 1 ){
				if ( $("#expectShipDate").val() == "" ){
					ydValidate("expectShipDate","请选择预计出货日");
					err++;
				}
			}
			if ( $("#productAttribute").val()  =="" ){
				ydValidate("productAttribute","请选择销售状态");
				err++;
			}
			if ( $("#showSeq").val() == "" ){
				ydValidate("showSeq","请输入排序【000～999】");
				err++;
			}
			<c-rt:if test="${empty product.productId}">
			try{
				if($("#cost").val()==''){
					$("#cost").val()=0.00;
				}
				if ($('input[name=type]:checked').val() != '2' ) {
					if (parseFloat($("#cost").val()) <= 0.00 ){
						ydValidate("cost","非赠品成本必须大于 0.00");
						err++;
					}
				} else {
					if (parseFloat($("#cost").val()) < 0.00 ){
						ydValidate("cost","成本小于 0.00");
						err++;
					}
				}
			} catch (errMsg) {
				ydValidate("cost","请输入成本");
				err++;
			}
			</c-rt:if>
			if ($("#price").val() == "" || parseInt($("#price").val(),10) == 0 ){
				ydValidate("price","请输入厂商建议售价");
				err++;
			}
			if ($("#tax").val() == "" ){
				ydValidate("tax","请输入税率类别");
				err++;
			}			
			if ($("#length").val() == "" || $("#length").val() == "请输入整数"){
				ydValidate("length","请输入长");
				err++;
			}
			if ($("#width").val() == "" || $("#width").val() == "请输入整数"){
				ydValidate("width","请输入宽");
				err++;
			}
			if ($("#height").val() == "" || $("#height").val() == "请输入整数"){
				ydValidate("height","请输入高");
				err++;
			}
			if ($("#weight").val() == "" || $("#weight").val() == "请输入整数"){
				ydValidate("weight","请输入重量");
				err++;
			}
			if ($("#unit").val() == "" || $("#unit").val() == "例如：件、个、罐、只"){
				ydValidate("unit","请输入單位");
				err++;
			}
			if ( $("#supplierIdParam").val() == ""){
				ydValidate("supplierIdParam","请选择供应商");
				err++;
			}
			if ( $("#supplierIdParam").val() == "010000" || $("#supplierIdParam").val() == "010001"){
				<c-rt:if test="${empty product.productId}">
					if ( $('input[name=isScm]:checked').val() == 'Y' ){
						ydValidate("supplierIdParam","若供应商为万美供应商，采购模式不可为转单");
						err++;
					}
				</c-rt:if>
				<c-rt:if test="${not empty product.productId}">
					if ( "${product.isScm}" == "Y" ){
						ydValidate("supplierIdParam","若供应商为万美供应商，采购模式不可为转单");
						err++;
					}
				</c-rt:if>
				if (  $("#twSupplierIdParam").val() == "" ) {
					ydValidate("twSupplierIdParam","若供应商为万美供应商，台湾供应商为必填");
					err++;
				}
			}
			//if ( $("#brandIdParam").val() == ""){
				//alert("请选择品牌");
				//$("#brandIdParam").focus();
				//return false;
			//}
			if ( $("#pm").val() == ""){
				ydValidate("pm","请选择主要负责PM");
				err++;
			}
			if ($("#organization").val() == ""){
				ydValidate("organization","请选择PM所属部门");
				err++;
			}
			if( $("#brief").val() == ""){
				ydValidate("brief","请输入商品特色");
				err++;
			}else{
			 var xxx = $("#brief").val().length;
			 var k = 0;
			 for(var i = 0 ; i < xxx; i++ ){
				 if ( $("#brief").val().charAt(i) == "\n"){
					 k++;
				 }
			 }
			 if ( k > 2 ){
				 ydValidate("brief","商品特色最多只能输入三行");
				 err++;
			 }
			 if ( k == 0 ){
				 if ( $("#brief").val().length > 30 ){
					 ydValidate("brief","商品特色第1行字数长度 超过30");
					 err++;
					 brief_result = false;
				 }
			 }else{
				 if ( $("#brief").val().indexOf("\n") != -1 ){
					 var briefArray = $("#brief").val().split("\n");
					 var ii = 0;
					 while( brief_result && ii <=briefArray.length-1 && ii < 3) {
						 if ( briefArray[ii].length > 30 ){
							 ydValidate("brief","商品特色第" + (ii+1) + "行字数长度 超过30");
							 err++;
							 brief_result = false;
						 }
						 ii++;
					 }
				 }
			 }
			}			
			if ( brief_result == false) return false;
			var description = CKEDITOR.instances.description.getData();
			description = description.replace("<br />","");
			description = description.replace("<br>","");
			description = trim(description);
			if(description==""){
				ydValidate("description","请输入商品描述");
				$("#description_focus").focus();
				err++;
			}
			$("#description").val(description);
			var details = CKEDITOR.instances.details.getData();
			details = details.replace("<br />","");
			details = details.replace("<br>","");
			details = trim(details);
			if(details==""){
				ydValidate("details","请输入规格参数");
				$("#details_focus").focus();
				err++;
			}			
			$("#details").val(details);
			if(CKEDITOR.instances['scmNotice']){
				var scmNotice = CKEDITOR.instances.scmNotice.getData();
				scmNotice = scmNotice.replace("<br />","");
				scmNotice = scmNotice.replace("<br>","");
				scmNotice = trim(scmNotice);
				$("#scmNotice").val(scmNotice);
			}else{
				$("#scmNotice").val("");
			}
			$("#flag").val(flag);
			if ($('input[name=channelFirm]').is(":checked") == false){
				ydValidate("channelFirmMode","请选择供应商来源");
				$("#cfmf").focus();
				err++;
			}
			/*
			if ($("#prpsShelfPrice").val() == "" ){
				alert("请输入提报耀点价");
				$("#prpsShelfPrice").focus();
				return false;
			}	
			if ( parseFloat($("#prpsShelfPrice").val()) == 0.00){
				alert("提报耀点价不可等于0");
				$("#prpsShelfPrice").focus();
				return false;
			}
			*/
			
			if ( err == 0){
				$.ajax({
				    url: '${midContextPath}/product2/findSupplierApply.do',
				    type: 'post',
				    dataType: 'json',
				    data: {editsupplier:$("#supplierIdParam").val()},
				    cache: false,
				    success: function(spResult){
				    	supplierCallback(spResult);
						}
				});
			}
			//else{
			//	disabledBtn();
			//}	
	 }

	
	
	function supplierCallback(spResult){
		var rsVal = spResult.split(",");
			// 转单商品&非转单供应商=>alert 說明 & update 商品
		<c-rt:if test="${empty product.productId or (empty product.productId and copy eq 'Y')}">
			if ( $('#isScmY:checked').val() == 'Y' ){ //轉單商品
				if ( rsVal[0] == "false" ){
					return ydValidate("supplierIdParam","供应商发货资料不正确"); 
				 }
				 if ( rsVal[1] == "N" ){
					 $("#supplierIdParam").show();
					 return ydValidate("supplierIdParam","供应商为非转单供应商,采购模式只可为进仓或BO"); 
				 }
				 if ( rsVal[0] == "true" && rsVal[1] == "Y" ){
					 disabledBtn();
				 } 
			}else{// 轉單供應商&非轉單商品 要異動商品的轉單資料=>不理会
				 disabledBtn();
			}
		</c-rt:if>
		<c-rt:if test="${not empty product.productId}">
			if ( "${product.isScm}" == 'Y'){//轉單商品
			 if ( rsVal[0] == "false" ){
				return ydValidate("supplierIdParam","供应商发货资料不正确"); 
			 }
			 if ( rsVal[1] == "N" ){
				 $("#supplierIdParam").show();
				 return ydValidate("supplierIdParam","供应商为非转单供应商,采购模式只可为进仓或BO"); 
			 }
			 if ( rsVal[0] == "true" && rsVal[1] == "Y" ){
				 disabledBtn();
			 } 
		 }else{// 轉單供應商&非轉單商品 要異動商品的轉單資料=>不理会
			 disabledBtn();
		 }		
		</c-rt:if>
	} 

	function initType(obj){
		defultType();
		if ( obj == "N" ) {//PO
			if ($('input[name=type]:radio:checked').val() != 1 ) {
				$("#type1").hide();//預購
				<yaodian100:checkPermission permissions="ROLE_PMPO">
				$("#type1").show();//預購
				</yaodian100:checkPermission>
		  }
		}
	}

	function initDeliveryDay(isScm,type){
		defaultDeliveryDay();
		if ( isScm == "B" || isScm == "Y" ){//BO&SCM
			if ( type == "0" || type == "1"){//一般&預購
				$("#showUseDeliveryDay").show();
			  $("input[name=useDeliveryDay][type=radio]").attr("checked",'N');
			  if ( type == "1" ){
				  $("#showExpectShipDate").show();
			  }
			}
			if ( isScm == "Y" ){//转单商品不允许限制cod
				$("#canUseCodTr").hide();
			}else{
				$("#canUseCodTr").show();
			}
		}
		if ( isScm == "N" ) {//PO
			if (type != 1 ) {
				$("#type1").hide();//預購
				<yaodian100:checkPermission permissions="ROLE_PMPO">
				$("#type1").show();//預購
				</yaodian100:checkPermission>
		  }
			$("#canUseCodTr").show();
		}
		if ( type == "1" ){
			$("#showExpectShipDate").show();
		} else {
			$("#showExpectShipDate").hide();
		}
	}

	function defultType(){
		$("#type0").show();//一般
		$("#type1").show();//預購
		$("#type2").show();//贈品
		$("#type3").show();//配件
		$("#type7").show();//限定立即购买商品
	}

	//訂制天數預設值
	function defaultDeliveryDay(){
		$("#showUseDeliveryDay").hide();
	  $("input[name=useDeliveryDay][type=radio]").attr("checked",'');
	  $("#deliveryDay").val("0");
		$("#showDeliveryDay").hide();
	}
	 
	//计算体积
	function calcVolume(){
		var length = $("#length").val();
		if ( "" == length || "请输入整数" == length )
			length = 0;
		var width = $("#width").val();
		if ( "" == width || "请输入整数" == width )
			width = 0;
		var height = $("#height").val();
		if ( "" == height || "请输入整数" == height )
			height = 0;
		$("#volume").val(length* width*height);
	}	
 	//购物须知ajax
	function orderNoticeCallback(jsonOrderNotice){
		CKEDITOR.instances.orderNotice.setData(jsonOrderNotice);
	}	
	//判断是否为最底层
 	function checkIsEndNode(){
  	$.post("${midContextPath}/product2/getJsonCategoryData.do",{mainCategoryId : $("#tempCategoryId").val()},endNodeCallback,"json");
 	}	
 	function endNodeCallback(categoryResult){
 		$("#isEndNode").val(categoryResult);
 	}
	function elementSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}         		 
				if ( categories[i].id == tempId[1] ){
					$('#elementSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 1 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[1]},attributeSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}
         		 if(categories[i].isVisible=="N"){
         			 cmark=cmark+'※';//是否可見
        		} 
					$("#isEndNode").val(categories[i].isEndnode);
					$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
	}
	function attributeSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[2] ){
					$('#attributeSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 2 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[2]},itemSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
	}
	function itemSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[3] ) {
					$('#itemSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 3 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[3]},unitSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
	}
	function unitSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[4] ) {
					$('#unitSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 4 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[4]},listSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
	}
	function listSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[5] ) {
					$('#listSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
	}			
	//组合目录路径
	function combineCategoryPath(){
		var categoryTemp = $('#categorySelect option:selected').text(); 
		var elementTemp =  $('#elementSelect option:selected').text();
		var attributeTemp = $('#attributeSelect option:selected').text();
		var itemTemp = $('#itemSelect option:selected').text();
		var unitTemp = $('#unitSelect option:selected').text();
		var listTemp = $('#listSelect option:selected').text();
		var textTemp ;
		if ( "" != categoryTemp ) textTemp = categoryTemp;
		if ( "" != elementTemp ) textTemp = textTemp + " > " +  elementTemp;
		if ( "" != attributeTemp ) textTemp = textTemp + " > " +  attributeTemp;
		if ( "" != itemTemp ) textTemp = textTemp + " > " +  itemTemp;
		if ( "" != unitTemp ) textTemp = textTemp + " > " +  unitTemp;
		if ( "" != unitTemp ) textTemp = textTemp + " > " +  listTemp;
		$("#tempCategoryFullPath").val(textTemp);
		checkIsEndNode();
	} 	

	//判斷目錄使用權限
	function checkPermission(categoryPath){
		if ( "" == $("#userPermissions").val() ){
			return true;
		}else{
			var permissions = $("#userPermissions").val().split(",");
			var rootId = categoryPath.split("/")[0];
			var result = false;
			for( i = 0 ; i < permissions.length; i++ ){
				if ( trim(permissions[i]) == trim(rootId)){
					result = true;
					break;
				}
			}
			return result;
		}
	}	   
	//判断是否有重复目录
	function duplicateCategoryIsExist(cId){
		var result = false;		
		if ( $("#secondCategoryId").val() == cId || $("#mainCategoryId").val() == cId ){
			result = true;
		}else{
			$('#addOnSelect option').each(function(){		
				if( $(this).val().split(",")[0] == cId){	
					result = true;
				}									
			});	
		}
		return result;
	}
	//清空输入栏位
	function clear_form_elements(){
			$('#elementSelect').find('option').remove().end();
	   	$('#attributeSelect').find('option').remove().end();
	   	$('#itemSelect').find('option').remove().end();
	   	$('#unitSelect').find('option').remove().end();
	   	$('#listSelect').find('option').remove().end();
			ele = $("#categoryConfigForm");
	    $(ele).find(':input').each(function() {
	        switch(this.type) {
	            case 'password':
	            case 'select-multiple':
	            case 'select-one':
	            case 'text':
	            case 'textarea':
                $(this).val('');
                break;
	            case 'checkbox':
	            case 'radio':
	                this.checked = false;
	        }
	    }); 
			$("#secondCategoryFullPath").text("");
	}		
	function loadDefaultCategory(){
		$('#elementSelect').find('option').remove().end();
   	$('#attributeSelect').find('option').remove().end();
   	$('#itemSelect').find('option').remove().end();
   	$('#unitSelect').find('option').remove().end();
   	$('#listSelect').find('option').remove().end();
		var tempId = $("#tempCategoryPath").val().split("/");
		$("#categorySelect").val(tempId[0]).attr("selected","selected");
		$.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[0]},elementSelectCallback,"json");
	}
</script>
<s:if test="hasActionErrors()">
	<s:actionerror cssClass="msg rn"/>
</s:if>
<s:if test="hasActionMessages()">
	<s:actionmessage cssClass="msg rn"/>
</s:if>
<p></p>
<h1>商品管理 - 商品主檔<br/>
<div class="f-link">
	<c-rt:if test="${not empty product.productId}">
		<a href="${midContextPath}/product2/copy.do?productId=${product.productId}">复制</a>
	</c-rt:if>
	<a href="${midContextPath}/product2/list.do">回商品列表页</a>
</div>
</h1>
<br/>
<!-- include product step menu -->
<jsp:include page="commonMenu2.jsp"/>
<s:form action="save.do" method="post" id="productForm">
<table class="tb-data" width="100%">
		<tr>
			<th>商品编号</th>			
			<td> 
				<c-rt:choose>
					<c-rt:when test="${empty product.productId}">系统流水号发放</c-rt:when>
					<c-rt:otherwise>
						${product.productId}
						<yaodian100:productImg productId="${product.productId}" postfix="m75" />
					</c-rt:otherwise>
				</c-rt:choose>
				<c-rt:if test="${nmMustOrderBuy=='Y'}"><span class="txt-red">此商品限立即购买</span></c-rt:if>
			</td>
			<th>商品状态</th>
			<td>
				<c-rt:if test="${not empty product.productId}">编辑</c-rt:if>
				<c-rt:if test="${empty product.productId and copy eq 'N'}">新增</c-rt:if>
				<c-rt:if test="${empty product.productId and copy eq 'Y'}">复制</c-rt:if>
			</td>
		</tr>
		<tr>
			<th><span class="txt-red">*</span>商品名称</th>			
			<td colspan="3">        
			   <input type="text" name="name" id="name" size="100" value="${product.productName}"/>
      </td>
	  </tr>
	  <tr>	
			<th><span class="txt-red">*</span>采购模式</th>			
			<td colspan="3">    
				<span id="scmMode"> 
				<c-rt:choose>
					<c-rt:when test="${not empty product.productId and product.isScm ne 'B'}">
						<c-rt:if test="${empty product.isScm or product.isScm eq 'N'}">进仓</c-rt:if>
						<c-rt:if test="${product.isScm eq 'B'}">BO</c-rt:if>
						<c-rt:if test="${product.isScm eq 'Y'}">SCM</c-rt:if>
						<input type="hidden" id="isScm" name="isScm" value="${product.isScm}"/>
					</c-rt:when>
					<c-rt:when test="${not empty product.productId and product.isScm eq 'B'}">
						<input id="isScmN" name="isScm" type="radio" value="N" <c-rt:if test="${empty product.isScm or product.isScm eq 'N'}">checked="checked"</c-rt:if>/>进仓
		    		<input id="isScmB" name="isScm" type="radio" value="B" <c-rt:if test="${product.isScm eq 'B'}">checked="checked"</c-rt:if>/>BO					
					</c-rt:when>
					<c-rt:otherwise>
						<input id="isScmN" name="isScm" type="radio" value="N" <c-rt:if test="${empty product.isScm or product.isScm eq 'N'}">checked="checked"</c-rt:if>/>进仓
						<input id="isScmB" name="isScm" type="radio" value="B" <c-rt:if test="${product.isScm eq 'B'}">checked="checked"</c-rt:if>/>BO
        		<input id="isScmY" name="isScm" type="radio" value="Y" <c-rt:if test="${product.isScm eq 'Y'}">checked="checked"</c-rt:if>/>SCM
					</c-rt:otherwise>
				</c-rt:choose>
				<a href="${midContextPath}/images/scm.png" target="_blank">采购模式说明</a>
				</span>
			</td>
		</tr>		 		  
		<tr>
			<th><span class="txt-red">*</span>商品型态 </th>			
			<td>
				<span id="typeMode">
					<c:if test="${product.productType eq '7'}">
						<span id="type7"><input name="type" type="radio" value="7" <c:if test="${product.productType eq '7'}">checked="checked"</c:if>/>限定立即购买商品</span>
					</c:if>
					<c:if test="${product.productType ne '7'}">
		        <span id="type0"><input name="type" type="radio" value="0" <c:if test="${empty product.productType or product.productType eq '0'}">checked="checked"</c:if>/>一般商品</span>
		        <span id="type1"><input name="type" type="radio" value="1" <c:if test="${product.productType eq '1'}">checked="checked"</c:if>/>预购</span>
		        <span id="type2"><input name="type" type="radio" value="2" <c:if test="${product.productType eq '2'}">checked="checked"</c:if>/>赠品</span>
		        <span id="type3"><input name="type" type="radio" value="3" <c:if test="${product.productType eq '3'}">checked="checked"</c:if>/>配件(加购)</span>
		        <span id="type7"><input name="type" type="radio" value="7"/>限定立即购买商品</span>
	        </c:if>
        </span>
      </td>
	  	<th><span class="txt-red">*</span>销售状态</th>
	  	<td>
	  		<s:select id="productAttribute" name="productAttribute" list="attributeMenu.options" listKey="key"  listValue="value.name" headerKey="" headerValue="---请选择销售状态---"/>
	  	</td>
	  </tr>
		<tr id="showExpectShipDate" style="display:none;">
			<th><span class="txt-red">*</span>预计出货日</th>
			<td colspan="3">
				<fmt-rt:formatDate value="${product.expectShipDate}" pattern="yyyy-MM-dd" var="fmtDate"/>
				<input type="text" name="expectShipDate" id="expectShipDate" value="${fmtDate}"/><br/>
				<span class="txt-gy">预购商品日期的最大值T+45天</span>
			</td>
		</tr>	
	 <c-rt:if test="${copy eq 'N'}">
		  <tr>
				<th >	建立者<br/>
					建立日期<br/>
					</th><td >
					 	${product.createUser}<br/>
						<fmt:formatDate value="${product.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /><br/>
						</td><th >
					修改者<br/>
					修改日期</th>	<td > 	
						${product.modifyUser}<br/>
						<fmt:formatDate value="${product.modifyDate}" pattern="yyyy-MM-dd HH:mm:ss" />
					</td>
		  	<td>
		  	</td>
		  </tr>
	  </c-rt:if>		  
		<tr>
			<th><span class="txt-red">*</span>商品分类</th>			
			<td colspan="3">
				<span class="txt-rd">○符号表示该分类为品牌;◎表活動</span><br/>
				<select id="categorySelect" name="categoryid" size="5" class="selCont">
         	<c-rt:forEach items="${rootCategories}" var="category">
						<option value="${category.id}">${category.name}(${category.id})</option>
					</c-rt:forEach>
        </select>       
        <select id="elementSelect" name="categoryid" size="5" class="selCont">            	
        </select>
        <select id="attributeSelect" name="categoryid" size="5" class="selCont">
        </select>
        <br/>
        <select id="itemSelect" name="categoryid" size="5" class="selCont">
        </select>
        <select id="unitSelect" name="categoryid" size="5" class="selCont">
        </select>
        <select id="listSelect" name="categoryid" size="5" class="selCont">
        </select>
        <br/>
        <div class="f-link">
        <a href="javascript:void(0);" id="mainCateBtn">设为主分类</a>
        <a href="javascript:void(0);" id="secondCateBtn">设为次分类</a>
        </div>
        <br/>
				主分类：<span id="mainCategoryFullPath"></span><br/>
				次分类：<span id="secondCategoryFullPath"></span><br/>
        <select id="addOnSelect" name="addOnSelect" size="10" class="selCont1" >
					<c-rt:forEach items="${productCategories}" var="productCategory">
						<option value="${productCategory.categoryId},${fn:split(productCategoryMap[productCategory.categoryId],',')[1]},${fn:split(productCategoryMap[productCategory.categoryId],',')[2]}">${fn:split(productCategoryMap[productCategory.categoryId],',')[0]},[${productCategory.createUser}/${productCategory.createDate}/${productCategory.modifyUser}/${productCategory.modifyDate}],${fn:split(productCategoryMap[productCategory.categoryId],',')[1]}</option>
					</c-rt:forEach>
				</select><br/>
				<div class="f-link">
					<span class="txt-gy">设置次分类可使该商品出现在不同的商品分类,次分类可设置多个</span>
					<a href="javascript:void(0);" id="removeSelect">删除所选次分类</a>
					<a href="javascript:void(0);" id="removeAllSelect">清除</a>
				</div>
			</td>
		</tr>	  
		<tr>
			<th><span class="txt-red">*</span>供应商</th>
			<td>

						<s:textfield name="editsupplier" id="supplierIdParam"  maxlength="6"/>
						<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
							id="getSupplier"/>
						<input type="text" id="supplierCompanyName" value="${supplierCompanyName}" readonly="readonly" size="60" style="border: 0px;"/>

				<c-rt:if test="${not empty product.productId and canUpdSupplier ne 'N' }"><br/>
					<span class="txt-gy">商品有库存情况下不可</span><a href="javascript:void(0);" onclick="chk24hr();">修改供应商</a>
				</c-rt:if>
			</td>
			<th><span class="txt-red">*</span>效期管理分类</th>
			<td>
				<s:select id="expireManage" name="expireManage" list="expireManageMenu.options" listKey="key"  listValue="value.name"/>
			</td>			
		</tr>		
	  <tr>
	  	<th><span class="txt-red">*</span>供应商来源</th>			
			<td colspan="3">
				<span id="channelFirmMode">
					<input id="cfmf"  name="channelFirm" type="radio" value="D" <c:if test="${product.channelFirm eq 'D'}">checked="checked"</c:if>/>自营商
	        <input name="channelFirm" type="radio" value="A" <c:if test="${product.channelFirm eq 'A'}">checked="checked"</c:if>/>经代销商
        </span>
			</td>
	  </tr>
		<tr id="twSupplier" style="display:none;">
			<th><span class="txt-red">*</span>台湾馆供应商</th>
			<td colspan="3">
				<c-rt:choose>
					<c-rt:when test="${not empty product.productId and editsupplier eq '010000' or editsupplier eq '010001'}">
						${editTwSupplier} ${twSupplierCompanyName}
						<s:hidden name="editTwSupplier" id="twSupplierIdParam"/>
					</c-rt:when>
					<c-rt:otherwise>
						<s:textfield name="editTwSupplier" id="twSupplierIdParam"  maxlength="6" readonly="readonly"/>
						<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
								id="getTwSupplier"/>
						<input type="text" id="twSupplierCompanyName" value="${twSupplierCompanyName}" readonly="readonly" size="60" style="border: 0px;"/>
					</c-rt:otherwise>
				</c-rt:choose>
			</td>
		</tr>		
		<tr>
			<th><span class="txt-red">*</span>厂商建议售价(市价)</th>			
			<fmt-rt:formatNumber value="${product.listPrice}" pattern="#####0.0" var="listPrice"/>
			<td><input id="price" name="price" type="text" value="${listPrice}"/><br/><span class="txt-gy">厂商建议售价小数点1位数后无条件舍去</span></td>
			<th><span class="txt-red">*</span>税率类别</th>			
			<td><input id="tax" name="tax" type="text" value="${product.taxClass}"/>%
			<br/><span class="txt-gy">例:17%,请直接输入17</span>
			</td>
		</tr>		
		<tr>
			<input type="hidden" name="showSeq" maxlength="3" id="showSeq" size="3" value="${product.showSeq}" />
			<th>${not empty product.productId ? '': '<span class="txt-red">*</span>'}商品成本</th>			
			<td>
			<c-rt:choose>
				<c-rt:when test="${not empty product.productId}">
					<fmt-rt:formatNumber value="${product.productCost}" pattern="#####0.00"/>
				</c-rt:when>
				<c-rt:otherwise>
					<fmt-rt:formatNumber value="${product.productCost}" pattern="#####0.00" var="productCost"/>
					<input id="cost" name="cost" type="text" value="${productCost}"/>	
				</c-rt:otherwise>
			</c-rt:choose>
			<br/><span class="txt-gy">商品成本小数点2位数后无条件舍去</span>
			<br/><span class="txt-gy">新增后无法修改,由后台计实后同步</span>
			</td>
			<th><span class="txt-red">*</span>退换货条件</th>			
			<td>
			<s:select id="returnRule" name="returnRule" list="returnRuleMenu.options" listKey="key"  listValue="value.name" />
			</td>
			<input type="hidden" name="nmMustOrderBuy" value="${nmMustOrderBuy}" />
		</tr>
		<tr>
			<th><span class="txt-red">*</span>商品体积</th>			
     	<td colspan="3">
				<span class="txt-red">*</span>长<input type="text" name="length" id="length" value="${product.productLength}"/>cm;
				<span class="txt-red">*</span>宽<input type="text" name="width" id="width" value="${product.productWidth}"/>cm;
				<span class="txt-red">*</span>高<input type="text" name="height" id="height" value="${product.productHeight}"/>cm;
				<span class="txt-red">*</span>体积<input type="text" name="volume" id="volume" value="${product.productVolume}" readonly="readonly"/>cm3;<br/>
       	<span class="txt-red">*</span>重量<input type="text" name="weight" id="weight" value="${product.productWeight}"/>g;
				<span class="txt-red">*</span>销售单位<input type="text" name="unit" id="unit" value="${product.productUnit}"/>
			</td>
	  </tr>		
		<tr>
			<th><span class="txt-red">*</span>物流运送温层类别</th>			
			<td>
	     	<input name="temperature" type="radio" value="1" <c:if test="${product.temperatureType eq '0' or product.temperatureType eq '1'}">checked="checked"</c:if>/>常溫
        <input name="temperature" type="radio" value="2" <c:if test="${product.temperatureType eq '2'}">checked="checked"</c:if>/>冷藏
        <input name="temperature" type="radio" value="3" <c:if test="${product.temperatureType eq '3'}">checked="checked"</c:if>/>冷冻
      </td>
      <th><span class="txt-red">*</span>是否需要防拆包材</th>
			<td>
				<input name="isAntiUnpacking" type="radio" value="Y" <c:if test="${empty product.isAntiUnpacking or product.isAntiUnpacking eq 'Y'}">checked="checked"</c:if>/>是
        <input name="isAntiUnpacking" type="radio" value="N" <c:if test="${product.isAntiUnpacking eq 'N'}">checked="checked"</c:if>/>否			
			</td>
	  </tr>	  
	 	<tr id="showUseDeliveryDay" style="display:none;">
		 	<th><span class="txt-red">*</span>订制商品</th>
	 		<td colspan="3">
				<input name="useDeliveryDay" type="radio" value="Y" <c:if test="${product.useDeliveryDay eq 'Y'}">checked="checked"</c:if>/>是<br/>
		    <input name="useDeliveryDay" type="radio" value="N" <c:if test="${product.useDeliveryDay eq 'N'}">checked="checked"</c:if>/>否
	 			<span id="showDeliveryDay" style="display:none;">订制所需时间
				<input id="deliveryDay" name="deliveryDay" type="text" value="${product.deliveryDay}"/>
				<span class="txt-gy">填写订制商品所需时间(不包含商品进仓所需时间)，订制时间与商品进仓时间总和将会显示于商品页</span>
				</span>
		  </td>
	 	</tr>		
	  <tr>
	  	<th><span class="txt-red">*</span>主要负责PM</th>			
			<td>
				<s:select id="pm" name="pm" list="users" listKey="username"  listValue="nameNative" headerKey="" headerValue="--请选择--"/>
			</td>
			<th><span class="txt-red">*</span>PM所属单位</th>
			<td><s:select id="organization" name="organization" list="groups" listKey="code"  listValue="description" headerKey="" headerValue="--请选择--"/></td>
	  </tr>	
	  <tr>
			<th>品牌</th>			
    	<td>
	     	<s:textfield name="editbrand" id="brandIdParam" />
				<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" id="getBrand"/>  
				<input type="text" name="brandName" id="brandName" value="${brandName}" readonly="readonly" size="60" style="border: 0px;"/>
			</td>
			<th><span class="txt-red">*</span>选择主档图显示类型</th>
	 		<td>
				<input name="graphicType" type="radio" value="S" <c:if test="${product.graphicType eq 'S'}">checked="checked"</c:if>/>方形图
		    <input name="graphicType" type="radio" value="R" <c:if test="${product.graphicType eq 'R'}">checked="checked"</c:if>/>长形图
		  </td>
		</tr>
		<tr>
			<th>提报耀点价</th>
	 		<td colspan="3">
	 			<fmt-rt:formatNumber value="${product.prpsShelfPrice}" pattern="#####0.00" var="prpsShelfPrice"/>
				<input id="prpsShelfPrice" name="prpsShelfPrice" type="text" value="${prpsShelfPrice}"/>
				<br/><span class="txt-gy">【※提报耀点价小数点2位数后无条件舍去】</span>
			</td>		
		</tr>
		<tr id="canUseCodTr">
			<th>是否允许COD付款</th>
			<td>
				<input name="canUseCod" type="radio" value="Y" <c:if test="${empty product.canUseCod or product.canUseCod eq 'Y'}">checked="checked"</c:if>/>是
  	    <input name="canUseCod" type="radio" value="N" <c:if test="${product.canUseCod eq 'N'}">checked="checked"</c:if>/>否
			</td>
			<th>是否评价尺码</th>
			<td>
				<input name="commentSize" type="radio" value="Y" <c:if test="${product.commentSize eq 'Y'}">checked="checked"</c:if>/>是
  	    <input name="commentSize" type="radio" value="N" <c:if test="${empty product.commentSize or product.commentSize eq 'N'}">checked="checked"</c:if>/>否
			</td>				
		</tr>		
		<!-- 
		<tr>
			<th>购买时是否需验证码</th>
			<td>
				<input name="isValidateNum" type="radio" value="Y" <c:if test="${empty product.isValidateNum or product.isValidateNum eq 'Y'}">checked="checked"</c:if>/>是
  	    <input name="isValidateNum" type="radio" value="N" <c:if test="${product.isValidateNum eq 'N'}">checked="checked"</c:if>/>否
			</td>
			<th>退换货时是否需取回</th>			
			<td>
	      <input name="returnpickup" type="radio" value="Y" <c:if test="${empty product.isReturnPickup or product.isReturnPickup eq 'Y'}">checked="checked"</c:if>/>是
        <input name="returnpickup" type="radio" value="N" <c:if test="${product.isReturnPickup eq 'N'}">checked="checked"</c:if>/>否
      </td>
    </tr>		
     -->
		<tr>
			<th><span class="txt-red">*</span>商品特色</th>			
			<td>
				<textarea id="brief" name="brief" cols="30" rows="3">${brief}</textarea>
			</td>
			<th>关键字</th>			
			<td>
				<textarea name="keyword" cols="30" rows="2">${product.productKeyword}</textarea>
				<br/><span class="txt-gy">关键字之类用逗号隔开</span>
			</td>
	  </tr>
		<tr>
			<th><span class="txt-red">*</span>商品描述</th>			
			<td colspan="3" id="description_focus">
				<input type="button" value="导入描述图" id="loadDescImg"/><br/>
				<textarea id="description" name="description" cols="150" rows="30">${description}</textarea>
				<script type="text/javascript">
				CKEDITOR.replace('description',{toolbar : 'product'});
				CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
	  </tr>
		<tr>
			<th><span class="txt-red">*</span>规格参数</th>			
			<td colspan="3" id="details_focus">
				<textarea id="details" name="details" cols="150" rows="30" >${details}</textarea>
				<script type="text/javascript">
					CKEDITOR.replace('details',{toolbar : 'product'});
					CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
	  </tr>
		<tr>
			<th>购物须知<br/>（若不填会带入该馆预设内容）</th>
			<td colspan="3">
				<textarea id="orderNotice" name="orderNotice" cols="150" rows="30">${orderNotice}</textarea>
				<script type="text/javascript">
				CKEDITOR.replace('orderNotice',{toolbar : 'product'});
				CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
		</tr>
		<tr id="showScmNotice">
			<th>特殊商品购物须知</th>
			<td colspan="3">
				<textarea id="scmNotice" name="scmNotice" cols="150" rows="30">${scmNotice}</textarea>
			</td>
		</tr>	
		<tr>
			<td colspan="4">
				<input type="hidden" name="minpo" value="1"/><!-- 最小采购量,default 1 -->
				<input type="hidden" name="maxpo" value="10"/><!-- 最大采购量,default 10 -->
				<input type="hidden" name="editleadtime" value="1"/><!-- 前置时间,default 1 -->		
				<input type="hidden" name="editDeliverGeoRange" value="1"/><!-- 运送限定区域,default 一区 -->
				<input type="hidden" name="delivertolerance" value="Y"/><!-- 是否允许超收,default Y -->		  	
				<input type="hidden" name="returnable" value="Y"/><!-- 退换货时是否需取回,defaut Y -->
				<input type="hidden" name="virtual" value="Y"/><!-- 虚拟商品,defaut Y -->
				<input type="hidden" id="isEndNode" name="isEndNode"/><!-- 是否为最底层目录  -->
				<!-- 主分類值 -->
				<input type="hidden" id="mainCategoryPath" name="mainCategoryPath" value="${mainCategoryPath}"/>
				<input type="hidden" id="mainCategoryId" name="mainCategoryId" value="${mainCategoryId}" />
				<!-- 次分類值 -->			
				<input type="hidden" id="secondCategoryPath" name="secondCategoryPath" value="" />
				<input type="hidden" id="secondCategoryId" name="secondCategoryId" value="" />
				<!-- 主次分類暫存值 -->
				<input type="hidden" id="tempCategoryId" name="tempCategoryId" value="${mainCategoryId}" />
				<input type="hidden" id="tempCategoryPath" name="tempCategoryPath" value="${mainCategoryPath}" />	
				<input type="hidden" id="tempCategoryFullPath" name="tempCategoryFullPath" value="${tempCategoryFullPath}" />	
				
				<input type="hidden" name="productId" value="${productId}"/>
				<input type="hidden" id="spId" value=""/>
				<input type="hidden" id="spName" value=""/>
				<input type="hidden" id="addonShowSeq" name="addonShowSeq" value="" />
				<input type="hidden" name="productIdParam" value="${product.productId}" />
				<input type="hidden" name="finalAddOnData" id="finalAddOnData" value=""/>
				<input type="hidden" id="userPermissions" value="${userPermissions}"/>				
				<input type="hidden" id="supplierScm" name="supplierScm"/>
				<input type="hidden" id="flag" name="flag"/>
				<input type="hidden" id="saveFlag" name="saveFlag" value=""/>
				<input type="button" name="submit1" id="save" value="保存商品"/>
				<input type="button" name="submit2" id="next" value="保存并到下一步"/>
				<input type="button" onclick="this.form.action='list.do';this.form.submit();" value="Cancel"/>
			</td>
	  </tr>
</table>
</s:form>
<div id="loadingImg" style="display:none;">
	<img src="/images/loading.gif"/>资料载入中,请稍候...
</div>